#define  _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int Compare(char s1[], char s2[], int sz)
{
	int i = 0;
	int flag = 1;
	for (i = 0; i < sz - 1; i++)
	{
		if (s1[i] != s2[i])
		{
			flag = 0;
			break;
		}
	}
	return flag;
}

void TurnLeft(char s[], int sz)
{
	int i = 0;
	int temp = s[0];
	for (i = 0; i < sz - 2; i++)
	{
		s[i] = s[i + 1];
	}
	s[i] = temp;
}

void Judge(char s1[], char s2[], int sz1, int sz2)
{
	int flag = 0;
	if (sz1 != sz2)
	{
		printf("%d\n", 0);
	}
	else
	{
		int count = sz2 - 2;
		do 
		{
			flag = 0;
			int n = Compare(s1, s2, sz1);
			if (n)
			{
				printf("%d\n", 1);
			}
			else
			{
				flag = 1;
				TurnLeft(s1, sz1);
				count--;
			}
			if (count == 0)
			{
				printf("%d\n", 0);
				flag = 0;
			}
		} while (flag);
	}
}

int main()
{
	char s1[] = "afcd";
	char s2[] = "cdeaf";
	int sz1 = sizeof(s1) / sizeof(s1[0]);
	int sz2 = sizeof(s2) / sizeof(s2[0]);
	char* p1 = s1;
	char* p2 = s2;
	Judge(p1, p2, sz1, sz2);
	return 0;
}